<?php
/**********************************************************************//**\file
	Armory Player XML

	Description: Provides specific functions for parsing the wowarmory.com
		player character information.
*******************************************************************************/

	class playerxml extends armoryxml
	{
		protected $player;

		public function __construct($name)
		{
			$this->get_cache('player', $name);
			$this->player = new playerdata($name, true);
		}

		public function parse()
		{
			# General
			$general = $this->xmldata->getElementsByTagName('character');

			foreach($general as $data)
			{
				$class = $data->getAttribute('classId');
				$gender = $data->getAttribute('genderId');
				$level = $data->getAttribute('level');
				$race = $data->getAttribute('raceId');

				$this->player->update_general($class, $gender, $level, $race);
			}

			unset($general);

			# Talents
			$talents = $this->xmldata->getElementsByTagName('talentSpec');

			foreach($talents as $data)
			{
				$talents1 = $data->getAttribute('treeOne');
				$talents2 = $data->getAttribute('treeTwo');
				$talents3 = $data->getAttribute('treeThree');

				$this->player->update_talents($talents1, $talents2, $talents3);
			}

			unset($talents);

			# Professions
			$professions = $this->xmldata->getElementsByTagName('skill');

			foreach($professions as $data)
			{
				$type = $data->getAttribute('key');
				$value = $data->getAttribute('value');

				$this->player->update_professions($type, $value);
			}

			unset($professions);
		}

		public function store()
		{
			$this->player->store();
		}

		public function debug()
		{
			$this->player->debug();
		}
	}
?>
